<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('六定审核')" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse" >
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="projectName"/>
                            </li>
                            <li>
                                <label>项目类型：</label>
                                <select name="projectType" th:with="type=${@dict.getType('eb_project_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>项目标签：</label>
                                <select id="projectLabel" name="projectLabel" th:with="type=${@dict.getType('eb_project_label')}" class="selectpicker" data-none-selected-text="所有" multiple>

                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>区划：</label>
                                <select name="projectArea" th:with="type=${@dict.getType('eb_project_area')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>审批状态：</label>
                                <select id="sixDoneStatus" name="sixDoneStatus" th:with="type=${@dict.getType('eb_approve_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset();$('#projectLabel').selectpicker('val',['noneSelectedText'])"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        $('#sixDoneStatus').val(20);

        var editFlag = [[${@permission.hasPermi('manage:project:edit')}]];
        var removeFlag = [[${@permission.hasPermi('manage:project:remove')}]];
        var prefix = ctx + "manage/approval";

        var projectTypeDatas = [[${@dict.getType('eb_project_type')}]];
        var projectLabelDatas = [[${@dict.getType('eb_project_label')}]];
        var approveStatusDatas = [[${@dict.getType('eb_approve_status')}]];
        var projectAreaDatas = [[${@dict.getType('eb_project_area')}]];

        $(function() {
            var options = {
                url: prefix + "/sixDone/list",
                detailUrl: prefix + "/detail/{id}",
                sortName: "updateTime",
                sortOrder: "desc",
                modalName: "项目信息",
                queryParams: queryParams,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'projectName',
                    title: '项目名称'
                },
                {
                    field: 'projectType',
                    title: '项目类型',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(projectTypeDatas, item.projectType);
                    }
                },
                {
                    field: 'projectLabel',
                    title: '项目标签',
                    formatter: function(value, item, index) {
                        var projectLabel = item.projectLabel;
                        var labelStr = "";
                        if (projectLabel) {
                            var labelArray = projectLabel.split(",");
                            for (var i=0; i < labelArray.length; i++) {
                                labelStr = labelStr + " " + $.table.selectDictLabel(projectLabelDatas, labelArray[i]);
                            }
                        }
                        return labelStr;
                    }
                },
                {
                    field: 'projectArea',
                    title: '区划',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(projectAreaDatas, item.projectArea);
                    }
                },
                {
                    field: 'sixDoneStatus',
                    title: '审批状态',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(approveStatusDatas, item.sixDoneStatus);
                    }
                },
                {
                    field: 'updateTime',
                    title: '更新时间'
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function(value, row, index) {
                        var actions = [];
                        var status = row.sixDoneStatus;
                        if (status == 20) {
                            actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.projectId + '\')"><i class="fa fa-check"></i>审核</a> ');
                        } else if (status == 30 || status == 40) {
                            actions.push('<a class="btn btn-primary btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.projectId + '\')"><i class="fa fa-search"></i>查看</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function queryParams(params) {
            var search = $.table.queryParams(params);
            return search;
        }

        /*项目列表-详细*/
        function detail(projectId) {
            var url = prefix + '/sixDone/detail/' + projectId;
            $.modal.openTab("资金审核详情", url);
        }
    </script>
</body>
</html>